//
//  WBBaseViewController.swift
//  学习微博
//
//  Created by zengyu on 2017/9/3.
//  Copyright © 2017年 weibo. All rights reserved.
//

import UIKit

class WBBaseViewController: UIViewController {

    
    /// 自定一个navigationBar导航条
    lazy var navigationBar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: UIScreen.cz_screenWidth(), height: 64))

    /// 自定义导航条目item
    lazy var navItem = UINavigationItem()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupUI()
        // Do any additional setup after loading the view.
    }
    
    override var title: String?{
        didSet {
            navItem.title = title
        }
    }
    
    
    
}


// MARK: - 设置界面
extension WBBaseViewController{
    func setupUI(){
        view.backgroundColor = UIColor.cz_random()
        //添加导航条
        view.addSubview(navigationBar)
        //将 item 设置给 bar
        navigationBar.items = [navItem]
        
        //设置 navBar 的渲染颜色
        navigationBar.barTintColor = UIColor.cz_color(withHex: 0xF6F6F6)
        //设置navBar 字体颜色
        navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.darkGray]
    }
}
